<?php

require_once 'classes/ChargeTypes.class.php';
require_once 'classes/ChargeCatagories.class.php';

$objChargeType 		= new ChargeTypes();
$arrobjChargeTypes 	= $objChargeType->fetchAllChargeTypes();
$objChargeCatagories 	= new ChargeCatagories();

// display( $arrobjPatients ); exit;

if( false == valArr( $arrobjChargeTypes ) ) {
	echo '<h2>Charges Types are not avaliable.</h2>';
} else {
?>
<html>
<head>
<link href="css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
<script src="js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="js/plugins/dataTables/dataTables.bootstrap.js"></script>
<script src="js/bootstrap-confirmation.js" type="text/javascript"></script>
<script>
	$(document).ready(function() {
		$('#dataTables-example').dataTable();
	});
</script>
<script>
function DeleteData(id){
               var r = confirm("Are You Sure Delete Charges Type?");
               if (r==true){
                  $.ajax({
                     type: "POST",
                     url: "modules.php?file=delete_charge_types",
                     data:{did:id},
                     beforeSend : function () {
                     },
                     success:function(){
					 location.reload();
                     }
                  });
               }else{   
               }
            }
</script>
<style>
	.thclass{
	font-size:12px;
	}
	.tbclass{
	font-size:12px;
	}
</style>
</head>
<body>
	<div style="margin-left:20px; margin-top: 10px;">
		<p>
			<a class="btn btn-outline btn-primary btn-xs" id="active" href="modules.php?file=charge_types&mid=<? echo $mid;?>&smid=<? echo $smid;?>" >Create New Charge Type</a>&nbsp;
			<a class="btn btn-outline btn-primary btn-xs" id="active" href="modules.php?file=view_charge_types&type=view&mid=<? echo $mid;?>&smid=<? echo $smid;?>" >View All Charge Type</a>
		</p>
	</div>
<div class="col-lg-12">
	<div class="panel panel-primary">
		
		<div class="panel-heading"><i class="fa fa-bell fa-fw"></i>Charges Type List</div>
		<div class="panel-body">
			<div class="table-responsive">
				<table class="table table-striped table-bordered table-hover" id="dataTables-example">
					<thead class="thclass">
						<tr>
							<th>Sr.No</th>
							<th>Charges catagory</th>
							<th>Name</th>
							<th>CA</th>
							<th>Out CA</th>
							<th>Below PL</th>
							<th>Edit</th>
							<th>Delete</th>
					</thead>
					<tbody class="tbclass">
					<?php 
					$intSnCount = 0;
					foreach( $arrobjChargeTypes as $objChargeType ) {
						$intSnCount++;
						$arrobjChargeCatagories = $objChargeCatagories->fetchChargeCatagoriesById($objChargeType->getChargeCatagoryId());
					?>
							<tr class="odd gradeX">
							<td><?  echo $intSnCount; ?></td>
							<td><? echo $arrobjChargeCatagories->getName(); ?></td>
							<td><? echo $objChargeType->getName(); ?></td>
							<td><? echo $objChargeType->getCbArea(); ?></td>
							<td><? echo $objChargeType->getOutOfCa(); ?></td>
							<td><? echo $objChargeType->getBelowPriorityLine(); ?></td>
							<td>
								<a href="modules.php?file=charge_types&charge_type_id=<? echo $objChargeType->getId(); ?>&mid=<? echo $mid;?>&smid=<? echo $smid;?>" title="Update patient information"><img src="images/icons/update.png" width="25" height="25"></a>
							</td>
							<td>
								<a id="delete_charge_type" onClick="DeleteData(<?echo $objChargeType->getId();?>);"><img src="images/icons/delete.jpg" width="25" height="25"></a>
							</td>
							</tr>
					<?
					} 
					?>
					</tbody>
				</table>
			</div>
		</div>
	</div>
</div>
</body>
</html>
<?php
}
?>